package cn.spike.rockcc.mq.consumer;

import cn.spike.rockcc.domain.CourseOrder;
import cn.spike.rockcc.domain.PayOrder;
import cn.spike.rockcc.service.ICourseOrderService;
import com.alibaba.fastjson.JSON;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author:spike
 * @create:2023-03-23 11:45
 */
@RocketMQMessageListener(
        consumerGroup = "service-consumer-courseOrder",
        topic = "pay-topic",
        selectorExpression = "payFlow-tags"
)
@Component
public class PayOrderConsumer implements RocketMQListener<String> {

    @Autowired
    private ICourseOrderService courseOrderService;

    @Override
    public void onMessage(String s) {
        PayOrder payOrder = JSON.parseObject(s, PayOrder.class);
        courseOrderService.updateCourseOrderByPayOrder(payOrder);
    }
}
